<?php
$serverpath=$_SERVER['DOCUMENT_ROOT'];
include ($serverpath.'/Classes/session.php');
include ($serverpath.'/Classes/Client.php');
$filename=$serverpath.'/users.txt';

$fp = fopen("$filename", "r");
$succesfull=false;
if ($fp){
	while (!feof($fp)) {
		$line=fgets($fp);
		$info = explode('|', $line);
		if ($info[1]=$_POST['userName']&&$info[2]=$_POST['password']){
			//Creo la Session
			$adminSession = new session($info[0],$info[1]);
			$serialize_session = serialize($adminSession);
			file_put_contents('store_adminSession',$serialize_session);
			$succesfull=true;
		}
	}
	fclose($fp);
	if($succesfull){
		header('Location: adminHome.php');
	}

}
?>
